package Dungeoneering.Puzzles;

import Dungeoneering.ActionHandlers.ActionHandler;
import Dungeoneering.Entities.Room;
import Dungeoneering.Utils.Utilities;
import Dungeoneering.api.methods.Objects;

public class ReturnTheFlow extends PuzzleStrategy{

	private static final int normalPillar = 54119;//might be more versions
	private static final int damagedPillar = 54123;
	private static final int fixedPillar = 54127;
	private static final int pedestal = 54111;
	private static final int completePedestal = 54115;
	private static final int[] rubble = {54131, 54139};
	private static final int[] fixedRubble = {54135, 54143};
	private static final int doorID = 54107;
	
	@Override
	public boolean detect(Room room) {
		if(room.containsLocations(pedestal))
			return true;	
		return false;
	}

	@Override
	public void solve(Room room) {
		// TODO solve it :p
		if(!detect(room))
			//TODO write an error message
			return;
		
		Utilities.thinkSleep();
		
		while(room.containsOneOfLocations(54123, 54131, 54139)) {	
			status = Status.TRYING_SKILL_ROOM;		
			while(room.containsLocations(54123)) {
				ActionHandler.interactLocation(Objects.getNearest(54123), "Fix");
				Utilities.randSleep(800);
			}
			while(room.containsLocations(54131)) {
				ActionHandler.interactLocation(Objects.getNearest(54131), "Mine");
				Utilities.randSleep(800);
			}
			while(room.containsLocations(54139)) {
				ActionHandler.interactLocation(Objects.getNearest(54139), "Mine");
				Utilities.randSleep(800);
			}	
		}
		status = Status.OPENING_DOOR;
		//TODO open doors
		Utilities.thinkSleep();
	}
}
